package logic

import (
	"context"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"gorm.io/gorm"
	"user_srv/model"
	"user_srv/user_proto"
)

func (s *Server) UpdateUserInfo(ctx context.Context, in *user_proto.UpdateUserInfoRequest) (*user_proto.UpdateUserInfoResponse, error) {
	u := model.User{
		Model:    gorm.Model{ID: uint(in.Id)},
		Mobile:   in.Mobile,
		Password: in.Password,
		NickName: in.NickName,
		BirthDay: in.BirthDay,
		Sex:      int(in.Sex),
		Age:      int(in.Age),
	}
	err := u.UpdateUserInfo()
	if err != nil {
		return nil, status.Error(codes.Internal, "修改用户信息失败")
	}
	return &user_proto.UpdateUserInfoResponse{}, nil
}
